package com.qingcheng.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.service.system.MenuService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 获取菜单
 */
@RestController
@RequestMapping("/menu")
public class MenuAllController {

    @Reference
    private MenuService menuService;

    //查询所有菜单
    @GetMapping("/findMenu")
    public List<Map> findMenu(){
        //获取当前登录名
        String loginName = SecurityContextHolder.getContext().getAuthentication().getName();
        //根据登录名所拥有的权限去筛选菜单
        return menuService.selectAllByLoginName(loginName);
        //return menuService.findAllMenu();
    }
}

